Stefan Agner [Tue, 14 Aug 2018 10:38:15 +0000 (12:38 +0200)]
Avoid race condition in case tests directory does not exist
Make sure the tests directory exists before symlinking files
into it.
Closes: #1703
Closes: #1704
Approved by: cgwalters
Alexander Larsson [Tue, 14 Aug 2018 08:09:32 +0000 (10:09 +0200)]
ostree_repo_pull_from_remotes_async: Fix leak of options
copy_option() unnecessarily passed ownership of the value
to g_variant_dict_insert_value, but that already refs, so it was leaked.
Closes: #1702
Approved by: cgwalters
Alexander Larsson [Mon, 13 Aug 2018 16:28:22 +0000 (18:28 +0200)]
ostree_repo_static_delta_generate: Fix leak
There is no need to ref the argument of g_variant_builder_add_value
Closes: #1701
Approved by: jlebon
Alexander Larsson [Mon, 13 Aug 2018 15:44:27 +0000 (17:44 +0200)]
Fix leak in ostree_repo_list_collection_refs
We need to have the g_auto(GLnxDirFdIterator) inside the loop, or
we don't correctly clean up when iterating several times.
Closes: #1700
Approved by: cgwalters
Jonathan Lebon [Mon, 30 Jul 2018 15:11:34 +0000 (11:11 -0400)]
lib/commit: Only auto-update summary if refs were written
Closes: #1693
Approved by: mwleeds
Jonathan Lebon [Mon, 30 Jul 2018 14:54:15 +0000 (10:54 -0400)]
lib/config: Deprecate commit-update-summary option
Now that we have `auto-update-summary`, there is no point in having
`commit-update-summary`. The latter also only had an effect through
the `commit` CLI command, whereas the former is embedded directly in
libostree.
There is one corner case that slips through: `commit` would update the
summary file even if orphan commits were created, which we no longer do
here. I can't imagine anyone relying on this, so it seems safe to drop.
Closes: #1689
Closes: #1693
Approved by: mwleeds
Jonathan Lebon [Mon, 30 Jul 2018 14:46:58 +0000 (10:46 -0400)]
lib/config: Rename change-update-summary to auto-...
Mildly bikeshed, though I find the name `auto-update-summary` to be
easier to grok than `change-update-summary`. I think it's because it can
be read as "verb-verb-noun" rather than "noun-verb-noun".
Closes: #1693
Approved by: mwleeds
Jonathan Lebon [Mon, 30 Jul 2018 14:40:20 +0000 (10:40 -0400)]
lib/refs: Use GLNX_HASH_TABLE_FOREACH_KV helper
Closes: #1693
Approved by: mwleeds
Matthew Leeds [Tue, 31 Jul 2018 03:05:56 +0000 (20:05 -0700)]
lib/repo-pull: Use correct keyring for dynamic remotes
Normally, a configured remote will only serve refs with one associated
collection ID, but temporary remotes such as USB drives or LAN peers can
serve refs from multiple collection IDs which may use different GPG
keyrings. So the OstreeRepoFinderMount and OstreeRepoFinderAvahi classes
create dynamic OstreeRemote objects for each (uri, keyring) pair. So if
for example the USB mounted at /mnt/usb serves content from the
configured remotes "eos-apps" and "eos-sdk", the OstreeRepoFinderResult
array returned by ostree_repo_find_remotes_async() will have one result
with a remote called something like
file_mnt_usb_eos-apps.trustedkeys.gpg and the list of refs on the USB
that came from eos-apps, and another result with a remote
file_mnt_usb_eos-sdk.trustedkeys.gpg and the list of refs from eos-sdk.
Unfortunately while OstreeRepoFinderMount and OstreeRepoFinderAvahi
correctly only include refs in a result if the ref uses the associated
keyring, the find_remotes_cb() function used to clean up the set of
results looks at the remote summary file and includes every ref that's
in the intersection with the requested refs, regardless of whether it
uses a different remote's keyring. This leads to an error when you try
to pull from a USB containing refs from different collection IDs: the
pull using the wrong collection ID will error out with "Refspec not
found" and the result with the correct keyring will then be ignored "as
it has no relevant refs or they have already been pulled." So the pull
ultimately fails.
This commit fixes the issue by filtering refs coming from a dynamic
remote, so that only ones with the collection ID associated with the
keyring remote are examined. This only needs to be done for dynamic
remotes because you should be able to pull any ref from a configured
remote using its keyring. It's also only done when looking at the
collection map in the summary file, because LAN/USB remotes won't have a
"main" collection ID set (OSTREE_SUMMARY_COLLECTION_ID).
Closes: #1695
Approved by: pwithnall
Colin Walters [Tue, 31 Jul 2018 21:04:26 +0000 (17:04 -0400)]
ostree-remount.service: RemainAfterExit=yes
This is standard practice for units like this; e.g. it's what
`systemd-remount-fs.service` does. I think it may be part of
or the whole cause for
https://github.com/projectatomic/rpm-ostree/issues/1471
I haven't reproduced the problem exactly but it seems to me that
if the unit starts and is GC'd, then when systemd goes to execute
a later unit it might end up restarting it.
A noticeable side effect of this is that `systemctl status ostree-remount`
exits with code `0` as expected.
Closes: #1697
Approved by: jlebon
bubblemelon [Tue, 24 Jul 2018 18:27:21 +0000 (11:27 -0700)]
bin/refs: Clarify --create error message
Fix ref create error when existing rev not specified.
Closes: #1690
Approved by: jlebon
Matthew Leeds [Fri, 13 Jul 2018 22:53:21 +0000 (15:53 -0700)]
config: Add a core/change-update-summary option
This commits adds and implements a boolean repo config option called
"change-update-summary" which updates the summary file every time a ref
changes (additions, updates, and deletions).
The main impetus for this feature is that the `ostree create-usb` and
`flatpak create-usb` commands depend on the repo summary being up to
date. On the command line you can work around this by asking the user to
run `ostree summary --update` but in the case of GNOME Software calling
out to `flatpak create-usb` this wouldn't work because it's running as a
user and the repo is owned by root. That strategy also means flatpak
can't update the repo metadata refs for fear of invalidating the
summary.
Another use case for this relates to LAN updates. Specifically, the
component of eos-updater that generates DNS-SD records advertising ostree
refs depends on the repo summary being up to date.
Since ostree_repo_regenerate_summary() now takes an exclusive lock, this
should be safe to enable. However it's not enabled by default because of
the performance cost, and because it's more useful on clients than
servers (which likely have another mechanism for updating the summary).
Fixes https://github.com/ostreedev/ostree/issues/1664
Closes: #1681
Approved by: jlebon
Matthew Leeds [Mon, 16 Jul 2018 21:54:57 +0000 (14:54 -0700)]
lib/repo: Take exclusive lock while generating summary
This ensures that commits aren't deleted and refs aren't added, removed,
or updated while the summary is being generated. This is in preparation
for adding a repo config option that will automatically regenerate the
summary on every ref change.
Closes: #1681
Approved by: jlebon
Jonathan Lebon [Wed, 25 Jul 2018 21:51:01 +0000 (17:51 -0400)]
lib: Fix some logic/error-checking code
Using `MAX(0, $x)` here is useless since we're comparing against an
unsigned integer. Just unpack this and only subtract if it's safe to do
so.
Also, explicitly check for `fd >= 0` rather than just `!= -1` to be sure
it's a valid fd. And finally, explicitly check the return value of
`g_input_stream_read_all` as is done everywhere else in the tree and
make it clear that we're purposely ignoring the return value of `_flush`
here, but not in other places.
Discovered by Coverity.
Closes: #1692
Approved by: cgwalters
Jonathan Lebon [Wed, 25 Jul 2018 21:49:12 +0000 (17:49 -0400)]
lib: Fix some minor memory leaks
I initially was going to add a `G_DEFINE_AUTOPTR_CLEANUP_FUNC` for
`FetchStaticDeltaData`, but it honestly didn't seem worth mucking around
ownership everywhere and potentially getting it wrong.
Discovered by Coverity.
Closes: #1692
Approved by: cgwalters
Jonathan Lebon [Wed, 25 Jul 2018 21:45:51 +0000 (17:45 -0400)]
lib: Check for NULL pointers in some more places
In `write_metadata_object()`, make sure when creating tombstone commits
that we're actually passed an expected checksum to use.
In `write_dir_entry_to_mtree_internal()`, sanity check that `dfd_iter`
is indeed not `NULL` before trying to dereference it.
Discovered by Coverity.
Closes: #1692
Approved by: cgwalters
Matthew Leeds [Mon, 23 Jul 2018 02:19:52 +0000 (19:19 -0700)]
man/ostree.repo-config: Update min-free-space-* docs
Now that it's possible to have both min-free-space-size and
min-free-space-percent set in a repo config, update the docs to make
the behavior clear in that case.
Closes: #1687
Approved by: jlebon
Matthew Leeds [Tue, 24 Jul 2018 21:52:24 +0000 (14:52 -0700)]
lib/repo-commit: Fix min-free-space error message
Since min_free_space_size_mb is considered before min_free_space_percent
in min_free_space_calculate_reserved_blocks(), it has to be considered
first when generating the error message in order for it to be accurate.
Closes: #1691
Approved by: jlebon
Colin Walters [Thu, 19 Jul 2018 12:46:23 +0000 (12:46 +0000)]
lib/pull: Fix minor memleak in error path
Spotted by a downstream Coverity build.
Closes: #1684
Approved by: jlebon
Umang Jain [Wed, 18 Jul 2018 05:36:48 +0000 (11:06 +0530)]
Post-release version bump
Closes: #1683
Approved by: cgwalters
Umang Jain [Wed, 18 Jul 2018 05:33:29 +0000 (11:03 +0530)]
Release 2018.7
Request via flatpak: mainly to port min-free-space-size
Closes: #1683
Approved by: cgwalters
Colin Walters [Fri, 20 Jul 2018 18:13:02 +0000 (14:13 -0400)]
ci: Mark insttests as not required
The reliablity has just not been what we need, and they haven't
yet caught any real bugs. Until I can carve off some time to
truly make this reliable let's just mark it as not required.
I'd like to gather more statistics on the failure scenarios.
Closes: #1686
Approved by: jlebon
Umang Jain [Mon, 16 Jul 2018 12:27:20 +0000 (17:57 +0530)]
lib/repo: Allow min-free-space-size and -percent to co-exist
Previously, we would error out if both of the options were mentioned
in the config file (even if one of them is disabled with 0). There
were few suggestions that this behavior was not quite right.
Therefore, instead of throwing error and exiting, it's preferred to
warn the user. Hence, the solution that worked out is:
* Allow both options to exist simulateneously
* Check each config's value and decide:
* If both are present and are non-zero, warn the user. Also, prefer
to use min-free-space-size over the another.
* If both are absent, then use -percent=3% as fallback
* Every other case is valid hence, no warning
https://phabricator.endlessm.com/T13698
(cherry picked from commit
be68991cf80f0aa1da7d36ab6e1d2c4d6c7cd3fb)
Signed-off-by: Robert McQueen <rob@endlessm.com>
Closes: #1685
Approved by: cgwalters
Emmanuele Bassi [Tue, 17 Jul 2018 21:33:19 +0000 (22:33 +0100)]
Add a check for gpg-error via pkg-config
Some downstreams — namely, the Yocto Project — ship gpg-error with a
pkg-config file, and modify gpg-error-config to error out when you try
using it instead of pkg-config.
We can check for gpg-error via pkg-config, and if it's not available,
fall back to gpg-error-config.
Signed-off-by: Emmanuele Bassi <ebassi@gnome.org>
Closes: #1682
Approved by: cgwalters
Colin Walters [Mon, 16 Jul 2018 20:23:01 +0000 (16:23 -0400)]
Update libglnx
For `renameat2()` fix to build with latest glibc (e.g. Fedora rawhide).
Update submodule: libglnx
Closes: #1680
Approved by: jlebon
Colin Walters [Mon, 16 Jul 2018 18:43:17 +0000 (14:43 -0400)]
build-sys: Link with gpg-error directly
We use the API, and not linking breaks the build with e.g.
`-fuse-ld=gold` in a Fedora 28 buildroot as gold doesn't do the
"search indirect dependencies" thing.
Closes: #1679
Approved by: jlebon
Colin Walters [Mon, 9 Jul 2018 16:22:10 +0000 (12:22 -0400)]
deploy: Fix overriding kernel args for staged deployments
This is the inverse of https://github.com/ostreedev/ostree/pull/1558
aka commits
cadece6c4f398ca61d21e497bd6e3fbb549f9cf6 and
3358698c86d80821d81443c906621c92672f99fb
Needed to fix `rpm-ostree kargs` test suite with default staging; skipping
a test here for now as eventually what we'll do is turn on the rpm-ostree
suite fully here.
Closes: #1677
Approved by: jlebon
William Manley [Fri, 22 Jun 2018 14:28:49 +0000 (15:28 +0100)]
ostree repo commit: Speed up composing trees with `--tree=ref`
Running `ostree commit --tree=ref=a --tree=dir=b` involves reading the
whole of a into an `OstreeMutableTree` before composing `b` on top. This
is inefficient if a is a complete rootfs and b is just touching one file.
We process O(size of a + size of b) directories rather than
O(number of touched dirs).
This commit makes `ostree commit` more efficient at composing multiple
directories together. With `ostree_mutable_tree_fill_empty_from_dirtree`
we create a lazy `OstreeMutableTree` which only reads the underlying
information from disk when needed. We don't need to read all the
subdirectories just to get the checksum of a tree already checked into the
repo.
This provides great speedups when composing a rootfs out of multiple other
rootfs as we do in our build system. We compose multiple containers
together with:
ostree commit --tree=ref=base-rootfs --tree=ref=container1 --tree=ref=container2
and it is much faster now.
As a test I ran
time ostree --repo=... commit --orphan --tree=ref=big-rootfs --tree=dir=modified_etc
Where modified_etc contained a modified sudoers file under /etc. I used
`strace` to count syscalls and I seperatly took timing measurements. To
test with a cold cache I ran
sync && echo 3 | sudo tee /proc/sys/vm/drop_caches
Results:
| | Before | After |
| -------------------- | ------ | ----- |
| Time (cold cache) | 8.1s | 0.12s |
| Time (warm cache) | 3.7s | 0.08s |
| `openat` calls | 53589 | 246 |
| `fgetxattr` calls | 78916 | 0 |
I'm not sure if this will have some negative interaction with the
`_ostree_repo_commit_modifier_apply` which is short-circuited here. I
think it was disabled for `--tree=ref=` anyway, but I'm not certain. All
the tests pass anyway.
I originally implemented this in terms of the `OstreeRepoFile` APIs, but
it was *way* less efficient, opening and reading many files unnecessarily.
Closes: #1643
Approved by: cgwalters
Alex Kiernan [Sat, 7 Jul 2018 21:35:35 +0000 (21:35 +0000)]
switchroot: Move late /run/ostree-booted creation to ostree-system-generator
When ostree-prepare-root is pid 1, ostree-prepare-boot defers creation of
/run/ostree-booted, which happens in ostree-remount, but that's too late
if we need ostree-system-generator to bind /var. Add the creation of the
/run/ostree-booted marker to ostree-system-generator based on the
existence of the ostree= kernel command line argument (which matches the
condition that ostree-remount uses).
Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Closes: #1675
Approved by: cgwalters
Alex Kiernan [Sat, 7 Jul 2018 13:18:40 +0000 (13:18 +0000)]
switchroot: Fix typo in comment ENINVAL => EINVAL
Closes: #1676
Approved by: cgwalters
Umang Jain [Thu, 5 Jul 2018 11:37:34 +0000 (17:07 +0530)]
repo: Reword min-free-space-size option's error strings
It is important that we use user-friendly error strings. The reason
being error strings are seen by users such as in GNOME Software's
error banner.
Closes: #1671
Approved by: jlebon
Umang Jain [Thu, 5 Jul 2018 11:01:48 +0000 (16:31 +0530)]
lib/repo-commit: Factor out min-free-space-size error reporting
Improves code readability.
Closes: #1671
Approved by: jlebon
Colin Walters [Tue, 3 Jul 2018 21:28:48 +0000 (17:28 -0400)]
deploy: Retain staged by default
For `rpm-ostree ex livefs` we have a use case of pushing a rollback
deployment. There's no reason this should require deleting the staged
deployment (and doing so actually breaks livefs which tries to access
it as a data source).
I was initially very conservative here, but I think it ends up
being fairly easy to retain the staged deployment. We need to handle
two cases:
First, when the staged is *intentionally* deleted; here, we just need
to unlink the `/run` file, and then everything will be sync'd up after
reloading.
Second, (as in the livefs case) where we're retaining it,
e.g. adding a deployment to the end. What I realized here is that
we can have the code keep `new_deployments` as view without staged,
and then when we do the final reload we'll end up re-reading it from
disk anyways.
Closes: #1672
Approved by: jlebon
Robert Fairley [Thu, 5 Jul 2018 18:59:24 +0000 (14:59 -0400)]
tests: Run network retries test for many retries directly
This runs a test involving many retries for the --network-retries
option directly rather than inside a conditional statement, so that
the command does not silently fail and allow the test to continue
running.
Closes: #1673
Approved by: jlebon
Robert Fairley [Thu, 5 Jul 2018 16:35:30 +0000 (12:35 -0400)]
ostree/pull: Add network-retries command line option
This exposes a way to specify from the command line the number
of times to retry each download after a network error. If a negative
value is given, then the default number of retries (5) is used. If 0
is given, then errors are returned without retrying.
closes #1659
Closes: #1669
Approved by: jlebon
Robert Fairley [Thu, 5 Jul 2018 16:30:05 +0000 (12:30 -0400)]
tests: Move assert_fail function to tests/libtest.sh
This moves the assert_fail function definition which was defined
and called in tests/test-remote-headers.sh. Done in preparation
for use of the assert_fail function in other test files.
Closes: #1669
Approved by: jlebon
Alex Kiernan [Wed, 4 Jul 2018 19:19:41 +0000 (19:19 +0000)]
build: Use ostree_prepare_root_CPPFLAGS for ostree-prepare-root
Swap from AM_CPPFLAGS to ostree_prepare_root_CPPFLAGS when compiling
ostree-prepare-root statically. This fixes a problem when you have
systemd and libmount, but only ostree_prepare_root_CPPFLAGS includes
-DHAVE_SYSTEMD_AND_LIBMOUNT=1.
Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Closes: #1670
Approved by: jlebon
Jonathan Lebon [Wed, 4 Jul 2018 15:59:18 +0000 (11:59 -0400)]
tests/installed: Add NOTE when re-using RPMs
One gotcha here is that we don't invalidate the RPMs if we're not
sitting on the same commit anymore. Shouldn't be too hard to fix, though
let's at least make a note of it for now.
Closes: #1668
Approved by: cgwalters
Colin Walters [Wed, 4 Jul 2018 15:57:50 +0000 (11:57 -0400)]
tests/installed: Add var-mount.yml destructive test
Closes: #1668
Approved by: cgwalters
Jonathan Lebon [Tue, 3 Jul 2018 21:41:45 +0000 (17:41 -0400)]
switchroot: Fix regression for separately mounted /var
I made a logical error in #1617 which resulted in the exact *opposite*
behaviour we want when `/var` is a separate mount.
Split this out and lower the number of negations to make it more obvious
that it's correct.
Closes: #1667
Closes: #1668
Approved by: cgwalters
Marcus Folkesson [Tue, 3 Jul 2018 08:02:46 +0000 (10:02 +0200)]
build: add ostree-soup-* to build process when configured with avahi
Avoid getting these link errors:
./.libs/libostree-1.so: undefined reference to `soup_uri_set_path'
./.libs/libostree-1.so: undefined reference to `soup_uri_new'
./.libs/libostree-1.so: undefined reference to `soup_uri_free'
./.libs/libostree-1.so: undefined reference to `soup_uri_set_scheme'
./.libs/libostree-1.so: undefined reference to `soup_uri_to_string'
./.libs/libostree-1.so: undefined reference to `soup_uri_set_host'
./.libs/libostree-1.so: undefined reference to `soup_uri_set_port'
collect2: error: ld returned 1 exit status
Reproduce with:
./configure --with-avahi --without-soup
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
Closes: #1666
Approved by: cgwalters
Alex Kiernan [Sat, 30 Jun 2018 17:03:51 +0000 (17:03 +0000)]
boot: Use emergency.target, not emergency.service
Follow systemd units in using emergency.target, not emergency.service
(which is the sole unit, by default, in emergency.target) so we can
easily reconfigure the units which are actived when entering
emergency mode.
Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Closes: #1665
Approved by: cgwalters
Umang Jain [Fri, 29 Jun 2018 20:40:12 +0000 (02:10 +0530)]
lib/repo: Minor fixes around min-free-space
Summary:
* Remove a useless if condition in prepare_transaction()
* Fix glnx_throw error propagation
* Integer overflow check while parsing min-free-space-size config
* Documentation fixes
Closes: #1663
Approved by: jlebon
William Manley [Mon, 25 Jun 2018 21:56:10 +0000 (22:56 +0100)]
OstreeMutableTree: Invalidate parent contents checksum when metadata changes
This bug has existed before the previous commit, but thanks to the previous
commit it is now easy to fix.
Closes: #1655
Approved by: cgwalters
William Manley [Mon, 25 Jun 2018 20:53:23 +0000 (21:53 +0100)]
OstreeMutableTree: Refactor: Add `parent` pointer
This implements a TODO item from
`ostree_mutable_tree_get_contents_checksum`. We now no-longer invalidate
the dirtree contents checksum at `get_contents_checksum` time - we
invalidate it when the mtree is modified. This is implemented by keeping
a pointer to the parent directory in each `OstreeMutableTree`. This gives
us stronger invariants on `contents_checksum`.
For even stronger guarantees about invariants we could make
`ostree_repo_write_mtree` or similar a member of `OstreeMutableTree` and
remove `ostree_mutable_tree_set_metadata_checksum`.
I think I've fixed a bug here too. We now invalidate parent's contents
checksum when our metadata checksum changes, whereas we didn't before.
Closes: #1655
Approved by: cgwalters
Colin Walters [Fri, 29 Jun 2018 17:53:54 +0000 (13:53 -0400)]
ci/flatpak: Fix to use built ostree version
Noticed as part of a random failure in this PR:
https://github.com/ostreedev/ostree/pull/1655
that we weren't actually testing the version of ostree
we built in git. Probably we should be generating RPMs but...later.
Closes: #1662
Approved by: jlebon
Philip Withnall [Tue, 26 Jun 2018 13:39:16 +0000 (14:39 +0100)]
lib/repo-commit: Abort a transaction if preparing it fails
If ostree_repo_prepare_transaction() fails, we should reset the
repository’s state so that the failed call was essentially idempotent.
Do that by calling ostree_repo_abort_transaction() on the failure path.
Typically, the way for preparing a transaction to fail is for its
GCancellable to be triggered, rather than because any of the operations
involved in preparing a transaction are particularly failure prone.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #1647
Approved by: cgwalters
Marcus Folkesson [Fri, 29 Jun 2018 08:16:41 +0000 (10:16 +0200)]
ci: exclude 'lib' from libsoup configure option
The option used by configure script is actually
--with-soup/--without-soup.
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
Closes: #1661
Approved by: jlebon
Colin Walters [Thu, 28 Jun 2018 19:18:27 +0000 (15:18 -0400)]
sysroot: Reject attempts to pin the staged deployment
From https://github.com/projectatomic/rpm-ostree/pull/1434#discussion_r198936674
To support it we'd have to actually write it to disk, which...let's
not try that right now.
Closes: #1660
Approved by: jlebon
William Manley [Thu, 28 Jun 2018 11:10:13 +0000 (12:10 +0100)]
tests: Save corefiles back to tests/ directory if one exists
Makes it easier to debug failures from the tests.
Closes: #1657
Approved by: cgwalters
Matthew Leeds [Thu, 28 Jun 2018 02:13:33 +0000 (19:13 -0700)]
create-usb: Tweak docs for --destination-repo
Make it show up in the help output as --destination-repo=DEST so it's
clear that it takes an argument.
Closes: #1656
Approved by: jlebon
Umang Jain [Tue, 26 Jun 2018 21:10:15 +0000 (02:40 +0530)]
lib/repo: Cleanup current boot's staging dir min-free-space-* checks are hit
min-free-space-* act as a gating condition whether to we want hold onto caches in
repo/tmp. If it is found that the free-disk space is going below this threshold,
we flag it as an error and cleanup current boot's staging directory.
Closes: #1602
Approved by: jlebon
Umang Jain [Tue, 26 Jun 2018 21:11:43 +0000 (02:41 +0530)]
lib/repo: cleanup_tmpdir should be executed after releasing lock file
Here's a subtle bug in abort_transaction():
One of the policies of cleaning up is to skip the current boot's staging
directory. The responsible function for this is cleanup_tmpdir() which tries
to lock each of the tmpdir before deleting it. When it comes to the current
boot's staging dir, it tries to lock the directory(again!) but fails as there
is already a lockfile present. Just because the current boot's staging dir was
meant to be skipped, the bug never surfaced up and wasn't catastrohpic.
if (!_ostree_repo_try_lock_tmpdir (dfd, path, &lockfile, &did_lock, error))
return FALSE;
if (!did_lock)
return TRUE; /* Note early return */
...
if (g_str_has_prefix (path, self->stagedir_prefix))
return TRUE; /* Note early return */
The actual check for skipping staging dir for current boot was never reached
because the function returned at did_lock failure.
Therefore, execute cleanup_tmpdir() after releasing the lockfile in
abort_transaction() so that cleanup_tmpdir gets a chance to lock current boot's
staging directory and succeed.
Closes: #1602
Approved by: jlebon
Javier Martinez Canillas [Wed, 27 Jun 2018 14:45:43 +0000 (16:45 +0200)]
deploy: Change BootLoaderSpec filenames so they can be used for sorting
Currently the BLS snippets are named ostree-$ID-$VARIANT_ID-$index.conf,
but the BLS config files are actually sorted by using the version field
which is the inverse of the index.
In most places, _ostree_sysroot_read_boot_loader_configs() is used to
get the BLS files and this function already returns them sorted by the
version field. The only place where the index trailing number is used is
in the ostree-grub-generator script that lists the BLS files to populate
the grub config file.
But for some bootloaders the BLS filename is the criteria for sorting by
taking the filename as a string version. So on these bootloaders the BLS
entries will be listed in the reverse order.
To avoid that, change the BLS snippets filename to have the version field
instead of the index and also to have the version before deployment name.
Make the filenames to be of the form ostree-$version-$ID-$VARIANT_ID.conf
so the version is before the deployment name.
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Closes: #1654
Approved by: cgwalters
Simon McVittie [Sun, 24 Jun 2018 11:56:49 +0000 (12:56 +0100)]
OstreeRepoFinderConfig: Fix guint/gsize confusion
If a function has a guint "out argument", passing a pointer to a gsize
is not, in general, valid. On an ILP64 platform there is no problem
since guint and gsize are identical, but on an LP64 platform it will
overwrite only the first word of the gsize, leaving the second word
unaffected. On little-endian machines, if the second word is
zero-initialized (as it is here), the result is numerically equal to
the guint, but on big-endian machines the result is around 4 billion
times what it should be, resulting in
ostree_repo_finder_config_resolve_async() reading past the end of
the array and causing undefined behaviour.
In practice this caused assertion failures (and consequently test
failures) on Debian's s390x (z/Architecture), ppc64 (64-bit PowerPC)
and sparc64 (64-bit SPARC) ports.
Closes: #1640
Signed-off-by: Simon McVittie <smcv@debian.org>
Closes: #1641
Approved by: cgwalters
Javier Martinez Canillas [Wed, 27 Jun 2018 10:19:26 +0000 (12:19 +0200)]
ostree-grub-generator: sort BLS files by version instead of alphabetically
The ostree-grub-generator populates the grub.cfg menu entries using the
BLS config files. But it uses the ls command that by default sorts the
entries alphabetically, so the order won't be correct if there are more
than 10 deployments, i.e:
$ ls -1 /boot/loader/entries/
ostree-fedora-workstation-0.conf
ostree-fedora-workstation-10.conf
ostree-fedora-workstation-1.conf
...
So instead the -v option should be used to make ls use version sorting:
$ ls -1 -v /boot/loader/entries/
ostree-fedora-workstation-0.conf
ostree-fedora-workstation-1.conf
...
ostree-fedora-workstation-10.conf
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Closes: #1653
Approved by: cgwalters
Jonathan Lebon [Mon, 25 Jun 2018 14:08:21 +0000 (10:08 -0400)]
tests/installed: Wait a bit more for http.server
And also print out the output if it still didn't start up in case there
are error messages hidden in there.
This should hopefully help with diagnosing the flakes we've been seeing
in starting it up.
Closes: #1652
Approved by: cgwalters
Colin Walters [Wed, 27 Jun 2018 12:17:31 +0000 (08:17 -0400)]
ci: Workaround getfedora.org/atomic_qcow2_latest being 404
Closes: #1652
Approved by: cgwalters
Matthew Leeds [Tue, 26 Jun 2018 05:50:58 +0000 (22:50 -0700)]
man/ostree.repo-config: Document collection-id
The collection-id option in the core section was recently made public
but not documented.
Closes: #1646
Approved by: cgwalters
William Manley [Sat, 23 Jun 2018 12:11:07 +0000 (13:11 +0100)]
Add test for composing trees in different ways
In preparation for adding `ostree commit` optimisations.
Closes: #1645
Approved by: jlebon
William Manley [Fri, 22 Jun 2018 11:00:29 +0000 (12:00 +0100)]
OstreeMutableTree: Document ostree_mutable_tree_ensure_dir
Closes: #1645
Approved by: jlebon
William Manley [Fri, 22 Jun 2018 10:37:37 +0000 (11:37 +0100)]
OstreeMutableTree: Document each private member of `OstreeMutableTree`
A prelude to my understanding. Unfortunately `OstreeMutableTree` provides
little encapsulation, as each member has setters† so it's difficult to come
up with a list of invariants.
† `files` and `subdirs` only have getters, but the getters return mutable
references to the internals, so we still can't reason about invariants.
Closes: #1645
Approved by: jlebon
Simon McVittie [Fri, 22 Jun 2018 00:10:55 +0000 (01:10 +0100)]
avahi: Fail immediately if we can't talk to D-Bus or Avahi
We special-case AVAHI_ERR_NO_DAEMON to not cause warnings, but if
we pass AVAHI_CLIENT_NO_FAIL to avahi_client_new, we never actually
see AVAHI_ERR_NO_DAEMON. Instead, we will get AVAHI_ERR_BAD_STATE
when we try to use the client.
Closes: #1618
Signed-off-by: Simon McVittie <smcv@debian.org>
Closes: #1639
Approved by: cgwalters
Umang Jain [Fri, 22 Jun 2018 18:06:21 +0000 (23:36 +0530)]
tests: Add tests for space checks during deltas codepath
Closes: #1614
Approved by: jlebon
Umang Jain [Tue, 19 Jun 2018 20:52:12 +0000 (02:22 +0530)]
lib/repo: Enforce min-free-space-* size check for regfiles in deltas
During the pull, there is an explicit check for free space on disk
vs. the size of uncompressed delta; But while writing the new content
objects that are generated, they have to honor min-free-space-* checks
too. We enforce this check in _bare_content_commit as that is where
we can know the final size of the new content object.
Closes: #1614
Approved by: jlebon
Colin Walters [Thu, 21 Jun 2018 14:17:28 +0000 (14:17 +0000)]
lib/repo: Fix 32 bit format string error
Jonathan Lebon [Thu, 21 Jun 2018 15:23:40 +0000 (11:23 -0400)]
Post-release version bump
Colin Walters [Tue, 19 Jun 2018 14:10:27 +0000 (14:10 +0000)]
Release 2018.6
Colin Walters [Mon, 18 Jun 2018 15:11:21 +0000 (11:11 -0400)]
tests/installed: Add a free-space success path test
We implicitly test the success percent path a lot, but not the
absolute path.
Closes: #1632
Approved by: jlebon
Colin Walters [Mon, 18 Jun 2018 14:47:49 +0000 (14:47 +0000)]
lib/repo: Do free space math under lock in error path
We were referencing the txn bits outside of the lock in the error
path. Generally shouldn't matter, but e.g. Rust wouldn't let us do this, and
race detector tooling will warn about it.
Closes: #1632
Approved by: jlebon
Colin Walters [Mon, 18 Jun 2018 14:40:24 +0000 (14:40 +0000)]
lib/repo: Rename free_space_size variable to free_space_mb
I generally like having variables include their units where applicable;
timer variables having `_secs` or `_ms`, etc.
Closes: #1632
Approved by: jlebon
Colin Walters [Mon, 18 Jun 2018 14:36:33 +0000 (10:36 -0400)]
lib/repo: Fix double-set-error in min-free-space-size code
We need to pass `NULL` as the error, we only care if the key exists;
otherwise we'll try to set the error twice.
Closes: #1632
Approved by: jlebon
Colin Walters [Fri, 15 Jun 2018 21:10:14 +0000 (21:10 +0000)]
lib/archive: Tell g-ir-scanner to ignore the private libarchive bits
Squashes this warning:
```
src/libostree/ostree-libarchive-private.h:46: syntax error, unexpected typedef-name in ' g_autoptr(OtAutoArchiveRead) a = archive_read_new ();' at 'OtAutoArchiveRead'
```
Closes: #1629
Approved by: jlebon
Dan Nicholson [Sat, 25 Jul 2015 16:51:14 +0000 (09:51 -0700)]
deploy: Delete .updated file from /etc and /var on new deployments
Systemd units using ConditionNeedsUpdate run if the mtime of .updated in
the specified directory is newer than /usr. Since /usr has an mtime of
0, there's no way to have an older .updated file. Systemd units
typically specify ConditionNeedsUpdate=/etc or ConditionNeedsUpdate=/var
to support stateless systems like ostree.
Remove the file from the new deployment's /etc and the OS's /var
regardless of where they came from to ensure that these systemd units
run when booting new deployments. This will provide a method to run
services only on upgrade.
Closes: #1628
https://bugzilla.gnome.org/show_bug.cgi?id=752950
Closes: #1631
Approved by: cgwalters
Matthew Leeds [Thu, 14 Jun 2018 21:33:10 +0000 (14:33 -0700)]
lib/prune: Don't modify dirent->d_name in place
Currently when I run `ostree prune` it hits a seg fault when the
hash_func is used (in this case g_str_hash) from the call stack
_ostree_repo_prune_tmp() -> g_hash_table_contains() ->
g_hash_table_lookup_node(). So the key, in this case dent->d_name, must
be corrupt in some way.
glnx_dirfd_iterator_next_dent() uses readdir() to get the dirent struct.
And according to the man page for readdir(3), "POSIX.1 explicitly notes
that this field should not be used as an lvalue" (in reference to
d_name). So this commit avoids modifying d_name in place and copies it
instead. This seems to avoid the seg fault.
Closes: #1627
Approved by: jlebon
Alexander Larsson [Wed, 13 Jun 2018 17:20:28 +0000 (19:20 +0200)]
ostree_repo_resolve_rev: Resolve refs set in the transaction
This allows you to get at the current commit for a ref pending in the transaction.
Closes: #1624
Approved by: cgwalters
Philip Withnall [Thu, 14 Jun 2018 15:47:43 +0000 (16:47 +0100)]
lib/repo-commit: Delay propagation of errors from abort_transaction()
If there’s a problem while aborting a transaction, store the error but
don’t report it until the end of the function — do a best effort at
clearing the rest of the transaction state first (since most of it
cannot fail).
If cleanup_tmpdir() fails (which, arguably, should not be a
showstopper), this allows a caller to recover and start a new
transaction in future.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #1626
Approved by: jlebon
Umang Jain [Mon, 11 Jun 2018 21:06:31 +0000 (02:36 +0530)]
lib/repo: Add min-free-space-size option
Similar to min-free-space-percent but it supports specific sizes
(in MB, GB or TB). Also, making min-free-space-percent and -size
mutually exclusive.
min-free-space-percent does not give a fine tuning of the free disk
space that a user might decide to keep. It can translate to very large
size (e.g. 1% = ~10GB on 1TB HDD) or very small (e.g. 1% = ~330MB on 32GB
system like Endless devices). Hence, it makes sense to introduce a config
option to honor specific size as per the user.
Closes: #1616
Approved by: jlebon
Matthew Leeds [Tue, 12 Jun 2018 02:09:28 +0000 (19:09 -0700)]
admin: Fix list of subcommands in help and manpage
This adds subcommands that were missing from the ostree-admin man page,
and makes cosmetic fixes there and in the --help output to ensure
alphabetical order and remove trailing whitespace.
Closes: #1621
Approved by: jlebon
Jonathan Lebon [Thu, 7 Jun 2018 18:42:42 +0000 (14:42 -0400)]
switchroot: Allow letting ostree-prepare-root mount /var
In some scenarios, it might make sense to let `ostree-prepare-root` do
the `/var` mount from the state root as before. For example, one may
want to do some system configuration before the switch root. This of
course comes at the expense of supporting `/var` as a mount point in
`/etc/fstab`.
Closes: #1617
Approved by: cgwalters
Matthew Leeds [Wed, 6 Jun 2018 21:34:01 +0000 (14:34 -0700)]
tests: Add test for including ostree.h
Closes: #1615
Approved by: jlebon
Matthew Leeds [Wed, 6 Jun 2018 20:41:37 +0000 (13:41 -0700)]
Fix building against old glib versions
We need to include libglnx.h in places where ostree-autocleanups.h is
included, so that we get backports of G_DEFINE_AUTOPTR_CLEANUP_FUNC and
friends.
Closes: #1615
Approved by: jlebon
Matthew Leeds [Wed, 6 Jun 2018 20:05:28 +0000 (13:05 -0700)]
Revert "lib: Fix building against old glib versions"
This reverts commit
f1d9196076d4aea1f64e0d2cbd17bfa2891b8c4c.
Since libglnx.h does not get installed, it can't be included in
ostree-autocleanups.h, which is included by ostree.h.
Closes: #1615
Approved by: jlebon
Matthew Leeds [Tue, 22 May 2018 22:55:14 +0000 (15:55 -0700)]
Make P2P API public (no longer experimental)
Currently the API that allows P2P operations (e.g. pulling an ostree ref
from a LAN or USB source) is hidden behind the configure flag
--enable-experimental-api. This commit makes the API public and makes
that flag essentially a no-op (leaving it in place in case we want to
use it again in the future). The P2P API has been tested over the last
several months and proven to work.
This means that since we're no longer using the "experimental" feature
flag, P2P builds of Flatpak will fail when using versions of OSTree from
this commit onwards, until Flatpak is patched in the near future. If you
want to build Flatpak < 0.11.8 with P2P enabled and link against OSTree
2018.6, you'll have to patch Flatpak. However, since Flatpak won't yet
have a hard dependency on OSTree 2018.6, it needs a new way to determine
if the P2P API in OSTree is available, so this commit adds a "p2p"
feature flag. This way the feature set is more semantically correct than
if we had continued to use the "experimental" feature flag.
In addition to making the P2P API public, this commit makes the P2P unit
tests run by default, removes the f27-experimental CI instance that's no
longer needed, changes a few man pages to reflect the changes, and
updates the bash completion script to accept the new commands and
options.
Closes: #1596
Approved by: cgwalters
Matthew Leeds [Thu, 31 May 2018 00:20:08 +0000 (17:20 -0700)]
lib: Fix building against old glib versions
This commit includes libglnx.h in ostree-autocleanups.h, so we get the
g_autoptr backports wherever they're needed. Also, remove the "#include
libglnx.h" lines elsewhere that are no longer needed.
Closes: #1596
Approved by: cgwalters
Jan Tojnar [Sat, 2 Jun 2018 22:25:31 +0000 (00:25 +0200)]
tests: Fix locale detection
When a locale with C.utf8 in its name (e.g. es_EC.utf8) was installed
on a system, the C.utf8 locale was chosen, even when it was not available.
This patch fixes the grep pattern to match whole lines returned by locale -a.
See: #1592
Closes: #1611
Approved by: cgwalters
Matthew Leeds [Wed, 30 May 2018 02:09:07 +0000 (19:09 -0700)]
ci: Use master branch as flatpak tag
Closes: #1607
Approved by: jlebon
Matthew Leeds [Wed, 30 May 2018 01:24:54 +0000 (18:24 -0700)]
ci: Bump flatpak build to F28
Closes: #1607
Approved by: jlebon
Philip Withnall [Mon, 28 May 2018 16:06:46 +0000 (17:06 +0100)]
lib/repo-pull: Support retries for delta superblocks
Use the recently introduced architecture for retrying network requests
on transient failure to do the same for delta superblock requests, now
that they’re queued.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #1600
Approved by: jlebon
Philip Withnall [Mon, 28 May 2018 15:55:05 +0000 (16:55 +0100)]
lib/repo-pull: Support queuing delta superblock requests
Just like all the other requests made for delta parts and objects by the
pull code, use a queue for delta superblocks. Currently this doesn’t do
any prioritisation or retries after transient failures, but it could do
in future.
This means that delta superblocks are now subject to the parallel
request limit in the fetcher, which was a problem highlighted here:
https://github.com/ostreedev/ostree/pull/1453#discussion_r168321706.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #1600
Approved by: jlebon
Philip Withnall [Wed, 30 May 2018 11:20:49 +0000 (12:20 +0100)]
lib/fetcher: Factor out HTTP status code handling from soup and curl
Use the same G_IO_ERROR_* values for HTTP status codes in both fetchers.
The libsoup fetcher still handles a few more internal error codes than
the libcurl one; this could be built on in future.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #1594
Approved by: jlebon
Philip Withnall [Wed, 30 May 2018 11:00:22 +0000 (12:00 +0100)]
lib/repo-pull: Add some missing assertions for progress statistics
Various of the counters already have assertions like this; add some more
for total paranoia.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #1594
Approved by: jlebon
Philip Withnall [Mon, 28 May 2018 15:25:53 +0000 (16:25 +0100)]
tests: Test pull behaviour when network timeouts occur
Extend test-pull-repeated.sh to test error 408 as well as error 500, to
ensure that the new retry-on-network-timeout code in ostree-repo-pull.c
correctly retries.
Rather than the 200 iterations needed for the error 500 tests, only do 5
iterations. The pull code internally does 5 retries (by default), which
means a full iteration count of 25. That seems to be sufficient to make
the tests reliably pass, in my testing — we can always bump it up to 200
/ 5 = 40 in future if needed (to put it in parity with the error 500
tests).
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #1594
Approved by: jlebon
Philip Withnall [Mon, 28 May 2018 15:24:33 +0000 (16:24 +0100)]
ostree/trivial-httpd: Add --random-408s command line option
This is exactly like the --random-500s option, except that it will cause
error 408 (request timeout) to be returned, rather than error 500
(internal server error).
This will be used in a following commit to test pull behaviour when
timeouts occur.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #1594
Approved by: jlebon
Philip Withnall [Fri, 25 May 2018 14:49:18 +0000 (15:49 +0100)]
lib/fetcher-soup: Map more SoupStatus codes to known GIOErrors
This allows the retry code in ostree-repo-pull.c to recover from (for
example) timeouts at the libsoup layer in the stack, as well as from the
GSocket layer in the stack.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #1594
Approved by: jlebon
Philip Withnall [Tue, 22 May 2018 11:21:45 +0000 (12:21 +0100)]
lib/repo-pull: Support retrying requests on transient network errors
Allow network requests to be re-queued if they failed with a transient
error, such as a socket timeout. Retry each request up to a limit
(default: 5), and only then fail the entire pull and propagate the error
to the caller.
Add a new ostree_repo_pull_with_options() option, n-network-retries, to
control the number of retries (including setting it back to the old
default of 0, if the caller wants).
Currently, retries are not supported for FetchDeltaSuperData requests,
as they are not queued. Once they are queued, adding support for retries
should be trivial. A FIXME comment has been left for this.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #1594
Approved by: jlebon
Matthew Leeds [Tue, 29 May 2018 01:03:42 +0000 (18:03 -0700)]
Fix building P2P code against old glib versions
When building the OstreeBloom code against old versions of glib, we have
to have the libglnx headers included so that it defines
G_DEFINE_AUTOPTR_CLEANUP_FUNC and friends for us.
This is similarly true for test-repo-finder-mount.c which indirectly
includes ostree-autocleanups.h.
Closes: #1605
Approved by: cgwalters
Matthew Leeds [Sat, 26 May 2018 01:01:35 +0000 (18:01 -0700)]
find-remotes: Fix unused variable warnings
Closes: #1605
Approved by: cgwalters
Matthew Leeds [Sat, 26 May 2018 00:48:39 +0000 (17:48 -0700)]
Allow compiling OstreeRepoFinderAvahi without libsoup
Closes: #1605
Approved by: cgwalters
Matthew Leeds [Fri, 25 May 2018 22:46:34 +0000 (15:46 -0700)]
Allow compiling with experimental API but without curl/soup
This commit rearranges a few things in ostree-repo-pull.c so that OSTree
will successfully compile with experimental API enabled and without
libsoup, libcurl, or avahi:
./autogen.sh --enable-experimental-api --without-soup --without-curl
--without-avahi
This is accomplished with two sets of changes:
1. Move ostree_repo_resolve_keyring_for_collection() so it can be used
even without libsoup or libcurl.
2. Add stub functions for ostree_repo_find_remotes_async() and
ostree_repo_pull_from_remotes_async(), and their _finish() counterparts,
so they return an error when libsoup or libcurl isn't available.
Closes: #1605
Approved by: cgwalters